<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    
    <title>用户管理</title>
    
	<link rel="stylesheet" type="text/css" href="<%=path%>/JS/extjs/resources/css/ext-all.css"/>
	<link rel="stylesheet" type="text/css" href="<%=path%>/JS/extjs/ux/gridfilters/css/GridFilters.css" />
    <link rel="stylesheet" type="text/css" href="<%=path%>/JS/extjs/ux/gridfilters/css/RangeMenu.css" />
    
	<script type="text/javascript" src="<%=path%>/JS/extjs/adapter/ext-base.js"></script>
	<script type="text/javascript" src="<%=path%>/JS/extjs/ext-all.js"></script>
	<script type="text/javascript" src="<%=path%>/JS/extjs/ext-lang-zh_CN.js"></script>
	
	<script type="text/javascript" src="<%=path%>/JS/extjs/ux/gridfilters/menu/RangeMenu.js"></script>
	<script type="text/javascript" src="<%=path%>/JS/extjs/ux/gridfilters/menu/ListMenu.js"></script>
	
	<script type="text/javascript" src="<%=path%>/JS/extjs/ux/gridfilters/GridFilters.js"></script>
	<script type="text/javascript" src="<%=path%>/JS/extjs/ux/gridfilters/filter/Filter.js"></script>
	<script type="text/javascript" src="<%=path%>/JS/extjs/ux/gridfilters/filter/StringFilter.js"></script>
	<script type="text/javascript" src="<%=path%>/JS/extjs/ux/gridfilters/filter/DateFilter.js"></script>
	<script type="text/javascript" src="<%=path%>/JS/extjs/ux/gridfilters/filter/ListFilter.js"></script>
	<script type="text/javascript" src="<%=path%>/JS/extjs/ux/gridfilters/filter/NumericFilter.js"></script>
	<script type="text/javascript" src="<%=path%>/JS/extjs/ux/gridfilters/filter/BooleanFilter.js"></script>
	
	
	
	<script type="text/javascript" src="<%=path%>/JS/jquery-1.7.2.js"></script>
	
	<script type="text/javascript">
	var showId = "";//展会ID
	var grid = null;//列表
	
	function openUpdateDialog(){
		Ext.useShims=true;

	    var win=new Ext.Window(
	    	    {title:"新增",
	        	    width:500,
	        	    height:490,
	        	    //html:updateDialogStr,
	        	    modal:true,
	        	    closeAction:"close",
	        	    buttons:[{
	        	    	text:"确认",handler:function(){
	        	    	
	        	    }}, {
		        	    text:"取消",handler:function(){
	        	    	win.close();
	        	    	}
			       	}]
	        	}); 
	    win.show();
		//点击右上角的关闭按钮后
	    win.on("close",function(){
		});
	}

	//等待提示
	function loadMask(msg){
		var loadMask = new Ext.LoadMask(Ext.getBody(),{msg:msg});
		return loadMask;
	}
	
	function deleteAudience(selID,store){
		var loadMask = new Ext.LoadMask(Ext.getBody(),{msg:"正在删除，请稍候..."});
		//var loadMask = loadMask();
		Ext.MessageBox.confirm("提示","确定删除？",function(btn){
			if(btn=="yes"){
				if(selID == ""){
					Ext.Msg.alert("提示","请选择删除行");
				}else if(selID != ""){
					loadMask.show();
					Ext.Ajax.timeout = 3 * 60 * 1000;
	        		Ext.Ajax.request({
	        		       url: '${pageContext.request.contextPath}/audienceManagerAction!deleteAudience.action',
	        		       method : 'POST',
	        		       params:{SelIDStr:selID},
	        			   success: function(response, options){
		        		   		var resultjson = Ext.util.JSON.decode(response.responseText);
	        			  	 	//alert("*********" + response.responseText);
	        			  	 	refresh(store);
	        			  	 	loadMask.hide();
	            			   	Ext.Msg.alert("提示","操作成功");
	        		       },
	        			   failure : function(request){   
	        		           Ext.MessageBox.show({   
	        		                   title : '提示',   
	        		                    msg : "操作失败",   
	        		                    buttons : Ext.MessageBox.OK,   
	        		                    icon : Ext.MessageBox.ERROR   
	        		                    });   
	        		       }
	        		  });
				}
			}else if(btn=="no" || btn=="cancel"){
				//return false;
			}
		});
	}

	function resendemail(selIDStr){
		var loadMask = new Ext.LoadMask(Ext.getBody(),{msg:"正在发送邮件，请稍候..."});
		if(selIDStr == ''){
			Ext.Msg.alert("提示","请选择用户");
		}else{
			loadMask.show();
			Ext.Ajax.timeout = 3 * 60 * 1000;
    		Ext.Ajax.request({
    		       url: '${pageContext.request.contextPath}/reSendEmailAction!reSendEmailToAudience.action?type='+type,
    		       method : 'POST',
    		       params:{selIDStr:selIDStr},
    			   success: function(response, options){
        		   		var resultjson = Ext.util.JSON.decode(response.responseText);
    			  	 	//alert("*********" + response.responseText);
    			  	 	var json = Ext.util.JSON.decode(resultjson.jsonStr);
    			  	 	var succ = json.success;
    			  	 	loadMask.hide();
    			  	 	if(succ){
	        			   	Ext.Msg.alert("提示","发送成功");
    			  	 	}else{
        			  	 	Ext.Msg.alert("提示","发送失败");
    			  	 	}
    			  	 	//refresh(store);
    		       },
    			   failure : function(request){   
    		           Ext.MessageBox.show({   
    		                   title : '提示',   
    		                    msg : "操作失败",   
    		                    buttons : Ext.MessageBox.OK,   
    		                    icon : Ext.MessageBox.ERROR   
    		                    });   
    		       }
    		  });
		}
	}
	
	function refresh(store){
		store.reload();
		//重新选择行
	    grid.getSelectionModel().clearSelections();
	    showId = "";//展会ID
	}
	</script>

  </head>
  
  <body>
    <script type="text/javascript">
    var audienceArr = Array();
    //当前选中行的id值
    var selID = "";
    var store = null;
    var type;
    
  		$(function(){
  			//当ajax写在此处时，会先加载页面，然后才会有json数据，所以，要在json数据返回以后，再回载页面
  		});
  		function InitMain(){
  			/*$.ajax({  
		url:'adminFindAllAudience',  
		type:'POST',  
		data:"{}",  
		dataType:'json',
		timeout: 100000,
		async:true,               
		error: function(a){                     
			alert('出错了');                 
		},   
		success:function (data) { 
			audienceArr = data.audienceList; 
		    //alert(Ext.encode(audienceArr));*/
		    
		    var url = document.location.href;
			var arrStr = url.substring(url.indexOf("?")+1).split("&");
			type=arrStr[0].replace("type=","");
			var encode = false;
			var local = true;//当前页查询，false为远程查询
		    
			//复选框
			var sm = new Ext.grid.CheckboxSelectionModel({checkOnly:false});
			//列过滤
			var filters = new Ext.ux.grid.GridFilters({
		        encode: encode,
		        local: local,
		        filters: [{
		            type: 'numeric',
		            dataIndex: 'id'
		        }, {
		            type: 'string',
		            dataIndex: 'audience_name'
		           // disabled: true
		        }, {
		            type: 'string',
		            dataIndex: 'audience_company'
		        }, {
		            type: 'string',
		            dataIndex: 'audience_department'
		        }, {
		            type: 'string',
		            dataIndex: 'audience_address1'
		        }, {
		            type: 'string',
		            dataIndex: 'audience_nation'
		        }, {
		            type: 'string',
		            dataIndex: 'audience_province'
		        }, {
		            type: 'string',
		            dataIndex: 'audience_city'
		        }, {
		            type: 'string',
		            dataIndex: 'audience_postcode'
		        }, {
		            type: 'string',
		            dataIndex: 'audience_tel'
		        }, {
		            type: 'string',
		            dataIndex: 'audience_fax'
		        }, {
		            type: 'string',
		            dataIndex: 'audience_mobile'
		        }, {
		            type: 'string',
		            dataIndex: 'audience_email'
		        }, {
		            type: 'string',
		            dataIndex: 'audience_weburl'
		        }, {
		            type: 'date',
		            dataIndex: 'audience_registerDate'
		        }, {
		            type: 'date',
		            dataIndex: 'audience_isAvailable'
		        }]
		    });
  			var cm = new Ext.grid.ColumnModel([
										  sm,
   	  	                 	  	          {
   	  	              	  	                  id       : 'id',
   	  	              	  	                  header   : 'ID', 
   	  	              	  	                  width    : 25, 
   	  	              	  	                  sortable : true, //排序
			   	  	              	  	      filter   : {
			   	  	            	              type : 'numeric'
			   	  	            	          },
   	  	              	  	                  dataIndex: 'id'
   	  	              	  	              },{
   	  	              	  	                  header   : '姓名', 
   	  	              	  	                  width    : 40, 
   	  	              	  	                  sortable : true, 
   	  	              	  	         		  filter   : {
			   	  	            	              type : 'string'
			   	  	            	          },
   	  	              	  	                 // renderer : 'usMoney', 
   	  	              	  	                  dataIndex: 'audience_name'
   	  	              	  	              },
   	  	              	  	              {
   	  	              	  	                  header   : '性别', 
   	  	              	  	                  width    : 35, 
   	  	              	  	                  sortable : true, 
   	  	              	  	                  renderer : showSex,
   	  	              	  	                  dataIndex: 'audience_sex'
   	  	              	  	              },{
   	  	              	  	                  header   : '公司', 
   	  	              	  	                  width    : 75, 
   	  	              	  	                  sortable : true, 
   	  	              	  	         		  filter   : {
			   	  	            	              type : 'string'
			   	  	            	          },
   	  	              	  	                 // renderer : 'usMoney', 
   	  	              	  	                  dataIndex: 'audience_company'
   	  	              	  	              },{
   	  	              	  	                  header   : '部门', 
   	  	              	  	                  width    : 75, 
   	  	              	  	                  sortable : true, 
   	  	              	  	         		  hidden   : true,
   	  	              	  	         		  filter   : {
			   	  	            	              type : 'string'
			   	  	            	          },
   	  	              	  	                 // renderer : 'usMoney', 
   	  	              	  	                  dataIndex: 'audience_department'
   	  	              	  	              },{
   	  	              	  	                  header   : '职位', 
   	  	              	  	                  width    : 75, 
   	  	              	  	                  sortable : true,
   	  	              	  	         		  hidden   : true,
   	  	              	  	         		  filter   : {
			   	  	            	              type : 'string'
			   	  	            	          },
   	  	              	  	                 // renderer : 'usMoney', 
   	  	              	  	                  dataIndex: 'audience_position'
   	  	              	  	              },{
   	  	              	  	                  header   : '邮寄地址', 
   	  	              	  	                  width    : 75, 
   	  	              	  	                  sortable : true, 
   	  	              	  	         		  hidden   : true,
   	  	              	  	                  // renderer : 'usMoney',
   	  	              	  	                  filter   : {
			   	  	            	              type : 'string'
			   	  	            	          }, 
   	  	              	  	                  dataIndex: 'audience_address1'
   	  	              	  	              },{
   	  	              	  	                  header   : '地址2', 
   	  	              	  	                  width    : 75, 
   	  	              	  	                  sortable : true, 
   	  	              	  	         		  hidden   : true,
   	  	              	  	                 // renderer : 'usMoney', 
   	  	              	  	                  dataIndex: 'audience_address2'
   	  	              	  	              },{
   	  	              	  	                  header   : '国家', 
   	  	              	  	                  width    : 75, 
   	  	              	  	                  sortable : true, 
   	  	              	  			  		  hidden   : true,
   	  	              	  			 		  filter   : {
			   	  	            	              type : 'string'
			   	  	            	          },
   	  	              	  	                 // renderer : 'usMoney', 
   	  	              	  	                  dataIndex: 'audience_nation'
   	  	              	  	              },{
   	  	              	  	                  header   : '省份', 
   	  	              	  	                  width    : 75, 
   	  	              	  	                  sortable : true, 
   	  	              	  			  		  hidden   : true,
   	  	              	  			 		  filter   : {
			   	  	            	              type : 'string'
			   	  	            	          },
   	  	              	  	                 // renderer : 'usMoney', 
   	  	              	  	                  dataIndex: 'audience_province'
   	  	              	  	              },{
   	  	              	  	                  header   : '城市', 
   	  	              	  	                  width    : 75, 
   	  	              	  	                  sortable : true, 
   	  	              	  			  		  hidden   : true,
   	  	              	  			 		  filter   : {
			   	  	            	              type : 'string'
			   	  	            	          },
   	  	              	  	                 // renderer : 'usMoney', 
   	  	              	  	                  dataIndex: 'audience_city'
   	  	              	  	              },{
   	  	              	  	                  header   : '邮编', 
   	  	              	  	                  width    : 75, 
   	  	              	  	                  sortable : true,
   	  	              	  			  		  hidden   : true, 
   	  	              	  	                 // renderer : 'usMoney', 
   	  	              	  	                  dataIndex: 'audience_postcode'
   	  	              	  	              },{
   	  	              	  	                  header   : '电话', 
   	  	              	  	                  width    : 75, 
   	  	              	  	                  sortable : true, 
   	  	              	  	                 // renderer : 'usMoney', 
   	  	              	  	                 filter   : {
			   	  	            	              type : 'string'
			   	  	            	          },
   	  	              	  	                  dataIndex: 'audience_tel'
   	  	              	  	              },{
   	  	              	  	                  header   : '传真', 
   	  	              	  	                  width    : 75, 
   	  	              	  	                  sortable : true,
   	  	              	  	         		  filter   : {
			   	  	            	              type : 'string'
			   	  	            	          }, 
   	  	              	  	                 // renderer : 'usMoney', 
   	  	              	  	                  dataIndex: 'audience_fax'
   	  	              	  	              },{
   	  	              	  	                  header   : '手机', 
   	  	              	  	                  width    : 60, 
   	  	              	  	                  sortable : true, 
   	  	              	  	         		  filter   : {
			   	  	            	              type : 'string'
			   	  	            	          },
   	  	              	  	                 // renderer : 'usMoney', 
   	  	              	  	                  dataIndex: 'audience_mobile'
   	  	              	  	              },{
   	  	              	  	                  header   : '邮箱', 
   	  	              	  	                  width    : 75, 
   	  	              	  	                  sortable : true, 
   	  	              	  	         		  filter   : {
			   	  	            	              type : 'String'
			   	  	            	          },
   	  	              	  	                 // renderer : 'usMoney', 
   	  	              	  	                  dataIndex: 'audience_email'
   	  	              	  	              },{
   	  	              	  	                  header   : '网址', 
   	  	              	  	                  width    : 75, 
   	  	              	  	                  sortable : true, 
   	  	              	  			  		  hidden   : true,
   	  	              	  	                 // renderer : 'usMoney', 
   	  	              	  	                  dataIndex: 'audience_weburl'
   	  	              	  	              },{
   	  	              	  	                  header   : '注册日期', 
   	  	              	  	                  width    : 85, 
   	  	              	  	                  sortable : true, 
   	  	              	  	         		  filter   : {
			   	  	            	              type : 'date'
			   	  	            	          },
   	  	              	  	                  renderer : Ext.util.Format.dateRenderer('Y-m-d H:i:s'), 
   	  	              	  	                  dataIndex: 'audience_registerDate'
   	  	              	  	              },{
   	  	              	  	                  header   : '是否可用', 
   	  	              	  	                  width    : 35, 
   	  	              	  	                  sortable : true, 
   	  	              	  	                  renderer : isVailabel, 
   	  	              	  			   		  hidden   : true,
   	  	              	  	                  dataIndex: 'audience_isAvailable'
   	  	              	  	              },{
   	  	              	  	                  header   : '展会名称', 
   	  	              	  	                  width    : 35, 
   	  	              	  	                  sortable : true, 
   	  	              	  			   		  hidden   : true,
   	  	              	  	                  dataIndex: 'showName'
   	  	              	  	              },{
   	  	              	  	                  header   : 'show_id', 
   	  	              	  	                  width    : 35, 
   	  	              	  	                  sortable : true, 
   	  	              	  			   		  hidden   : true,
   	  	              	  	                  dataIndex: 'show_id'
   	  	              	  	              }
   	  	              	  	          ]);

    	  	var record = Ext.data.Record.create([
    	  	                            {},
    	  	               				{name: 'id', type: 'int'},
    	  	          					{name: 'audience_name'},
    	  	          					{name: 'audience_sex'},
    	  	          					{name: 'audience_company'},
    	  	          					{name: 'audience_department'},
    	  	          					{name: 'audience_position'},
    	  	          					{name: 'audience_address1'},
    	  	          					{name: 'audience_address2'},
    	  	          					{name: 'audience_nation'},
    	  	          					{name: 'audience_province'},
    	  	          					{name: 'audience_city'},
    	  	          					{name: 'audience_postcode'},
    	  	          					{name: 'audience_tel'},
    	  	          					{name: 'audience_fax'},
    	  	          					{name: 'audience_mobile'},
    	  	          					{name: 'audience_email'},
    	  	          					{name: 'audience_weburl'},
    	  	          					{name: 'showName'},
    	  	          					{name: 'show_id'},
    	  	          					{name: 'audience_registerDate', type: 'date', dateFormat:'Y-m-d H:i:s'},
    	  	          					{name: 'audience_isAvailable'}
    	  	            	  	          ]);
    	  	var proxy = new Ext.data.HttpProxy({
        	 	url:'${pageContext.request.contextPath}/audienceManagerAction!findAudience.action?',
        	 	method:'post'
        	});  
    	  	var reader = new Ext.data.JsonReader({ totalProperty:'totalcount', root:'audienceList'},record);

  	  	    store = new Ext.data.Store({
  	  	        proxy:proxy,
  	  	        reader:reader
  	  	    });
  	  	    //分页添加参数
  	  	  	store.on('beforeload', function() {    //Ext.data.JsonStore读入数据之前的事件,store不需要在写baseParams,因为会覆盖掉. (每次调用都载入此函数,'load'则第一次不调用外,其余都调用).
	  	  	  this.baseParams = {
	  	  			showInfoId:showId
	  	  	  };
  	  	 	});
  	  	  	  store.load({
  	  	  			params : {start : 0,limit : 9}
  	  	  	  });

  	  	      //显示性别
  	  	      function showSex(val){//0为男，1为女
  	  	  	      if(val == "0"){
  	  	  	  	      return '先生';
  	  	  	      }else if(val == "1"){
  	  	  	  	      return '女士';
  	  	  	      }
  	  	  	      return val;
  	  	      }
			  //用户是否可用
	  	  	  function isVailabel(val) {
	  	        if (val == 0) {
	  	            return '否';
	  	        } else if (val == 1) {
	  	            return '是';
	  	        }
	  	        return val;
	  	      }
			  
			  var pageBar = new Ext.PagingToolbar({
	  	            pageSize: 9,
	  	            store: store,
	  	            displayInfo: true,
	  	            plugins: [filters],
	  	            displayMsg: '当前 {0} 到 {1}条 共 {2}条',
	  	            emptyMsg: "没有记录",
	  	            items:[
	  	                ]
	  	        });
  	  	      
  	  	      grid = new Ext.grid.GridPanel({
  	  	          store: store,
  	  	     	  cm: cm,
  	  	          stripeRows: true,
  	  	          autoExpandColumn: 'id',
  	  	          height: 250,
  	  	          width: "100%",
  	  	      	  plugins: [filters],
  	  	      	  loadMask: true,
	  	  	     // sm: new Ext.grid.RowSelectionModel({singleSelect: true}),
	  	  	      sm: sm,
	  			  viewConfig: {
	  				  forceFit: true
	  			  },
  	  	          stateful: true,
  	  	          stateId: 'grid',
  	  	      	  columnLines: true,
  	  	          region:"north",
  	  	          //分页
	  	  	      bbar: pageBar
  	  	      });
			//点击行数据显示问卷调查信息
      		var ct = new Ext.Panel({
      		//renderTo: 'binding-example',
      		frame: true,
      		//title: 'Book List',
      		width: 540,
      		height: 400,
      		layout: 'border',
      		region:'center',
      		items: [
      			grid,
      			{
      				id: 'detailPanel',
      				region: 'center',
      				autoScroll:true,
      				bodyStyle: {
      					//background: '#ffffff',
      					padding: '7px'
      				},
      				html: '<b>请选择一行数据查看详细信息。</b>'
          			}
          		]
          	});
          	//提示等待
      		var getQInfoMask = new Ext.LoadMask(Ext.getBody(),{msg:"正在获取信息，请稍候..."}); 

          	grid.getSelectionModel().on('rowselect', function(sm, rowIdx, r){
          		//提示等待
          		getQInfoMask.show(); 
          		
              	var id = r.data.id;
              	selID = id;
              	//alert(r.data.audience_city);
              	var currEmail = r.data.audience_email;
              	var currName = r.data.audience_name;
              	var currSex = r.data.audience_sex;
              	var currCompany = r.data.audience_company;
              	var currDepartment = r.data.audience_department;
              	var currPosition = r.data.audience_position;
              	var currNation = r.data.audience_nation + '/' + r.data.audience_province + '/' + r.data.audience_city;
              	var currAddress = r.data.audience_address1;
              	var currPostCode = r.data.audience_postcode;
              	var currMobile = r.data.audience_mobile;
              	var currTel = r.data.audience_tel;
              	var currUrl = r.data.audience_weburl;
              	var showName = r.data.showName;
              	var show_id = r.data.show_id;
              	//转换日期格式（原格式是web apr 6 00：00：00 UTC+0800 2005）
              	var currRegisterdate = Ext.util.Format.date(r.data.audience_registerDate,'Y-m-d H:i:s');
              	
              	//将选中行的ID赋给全局变量
          		Ext.Ajax.timeout = 3 * 60 * 1000;
        		Ext.Ajax.request({
        		       url: '${pageContext.request.contextPath}/adminGetQInfoAction.action',
        		       method : 'POST',
        		       params:{audienceId:id},
        			   success: function(response, options){
	        		   	 var resultjson = Ext.util.JSON.decode(response.responseText);
        			  	 //alert("*********" + response.responseText);
        			  	 var qTitleInfo = Ext.util.JSON.decode(resultjson.jsonStr).qtitleinfo;
        			  	 var qInfo = Ext.util.JSON.decode(resultjson.jsonStr).qinfo;
        			  	 //alert(Ext.util.JSON.encode(qInfo[0]));
        			  	 var data = qInfo[0];
        			  	 var bookTplStr = "";
        			  	 bookTplStr = "<table border='1' width='100%' align='left' cellpadding='0' cellspacing='0' style='margin-top:0px;font-size:15px;'>"
       			  		  +"<tr style='background-color:#fff'>"
       			  		  +"<td width='110'><b>邮箱</b></td><td>"+currEmail+"</td>"
       			  		  +"<td><b>姓名</b></td><td>"+currName+"</td><td><b>性别</b></td><td>"+(currSex=="0"?"先生":"女士")+"</td>"
    			  		  +"<td><b>公司</b></td><td>"+currCompany+"</td><td><b>单位</b></td><td>"+currDepartment+"</td>"
    			  		  +"<td><b>职位</b></td><td>"+currPosition+"</td>"
    			  		  +"</tr>"
    			  		  +"<tr>"
    			  		  +"<td><b>国家/地区</b></td><td>"+currNation+"</td><td><b>地址</b></td><td>"+currAddress+"</td>"
    			  		  +"<td><b>邮编</b></td><td>"+currPostCode+"</td><td><b>手机</b></td><td>"+currMobile+"</td>"
    			  		  +"<td><b>电话</b></td><td>"+currTel+"</td><td><b>网址</b></td><td>"+currUrl+"</td>"
    			  		  +"</tr>"
    			  		  +"<tr style='background-color:#fff'>"
    			  		  +"<td><b>注册日期</b></td><td>"+currRegisterdate+"</td>"
    			  		  +"<td><b>展会名称</b></td><td colspan='9'>"+showName+"</td>"
    			  		  +"</tr>";
            			  	// alert(qTitleInfo.length);
        			  	 for(var i=0;i<qTitleInfo.length;i++){
            			  	 //alert(qTitleInfo[i]);
            			  	 //alert(qTitleInfo[i].qtitlename + "--------" + qTitleInfo[i].qtitleid);
            			  	 var qtitlename = qTitleInfo[i].qtitlename;
            			  	 var qtitleid = qTitleInfo[i].qtitleid;
            			  	 if(i%2==0){
                			  	 bookTplStr += "<tr><td><b>";
            			  	 }else{
            			  		bookTplStr += "<tr style='background-color:#fff'><td><b>";
            			  	 }
            			  	 bookTplStr += qtitlename + " </b></td><td colspan='11'>{" + qtitleid + "}</td></tr>";
            			  	 
        			  	 }
        			  	 bookTplStr += "</table>";
        			  	 //alert(bookTplStr);

        			  	//var bookTplMarkup = ["用户名: {audience_name},<br/>手机: {audience_mobile},<br/>电子邮箱: {audience_email},<br/>Product Group: {ProductGroup}<br/>"];
                  		var bookTplMarkup = [bookTplStr];
              	  	    var bookTpl = new Ext.Template(bookTplMarkup);
         	           //alert(sm + "-----" + rowIdx + "\r\n" + Ext.util.JSON.encode(r.data));
                  		var detailPanel = Ext.getCmp('detailPanel');
                  		bookTpl.overwrite(detailPanel.body, data);
                  		
                  		//隐藏等待
                  		getQInfoMask.hide();
            			   
        		       },
        			   failure : function(request){   
        		           Ext.MessageBox.show({   
        		                   title : '操作提示',   
        		                    msg : "显示调查问卷信息出错",   
        		                    buttons : Ext.MessageBox.OK,   
        		                    icon : Ext.MessageBox.ERROR   
        		                    });   
        		       }
        		  });

          	});
          	grid.getSelectionModel().on('rowdeselect', function(sm, rowIdx, r){
              //	alert(1111);
              	var bookTplMarkup = ['<b>请选择一行数据查看详细信息。</b>'];
      	  	    var bookTpl = new Ext.Template(bookTplMarkup);
          		var detailPanel = Ext.getCmp('detailPanel');
          		bookTpl.overwrite(detailPanel.body, '');
          	});
          	//加载过滤按钮
          	grid.getBottomToolbar().add([
          		'->',
          		//{
                  //  text: '过滤条件',
                    //tooltip: '当前过滤条件',
                    //handler: function () {
                      //  var data = Ext.encode(grid.filters.getFilterData());
                        //Ext.Msg.alert('All Filter Data',data);
                    //} 
                //},
                {
                    text: '清除过滤',
                    handler: function () {
                        grid.filters.clearFilters();
                    } 
                },{
                    text: '重新加载',
                    handler: function () {
                        grid.reconfigure(store, cm);
                    } 
                },"-"
          		
          	]);
          	
          	var showInfoStore = new Ext.data.Store({
  			  proxy:new Ext.data.HttpProxy({url:'${pageContext.request.contextPath}/showInfoManagerAction!getAllShowInfo.action'}),
  			  reader:new Ext.data.JsonReader({root:'showInfoList'},['id','showName'])  //显示的字段名，与服务器端返回的json中字段一致
  			  });
  	  		showInfoStore.load();
          	
          	//展会form
          	var qTitleForm = new Ext.FormPanel({
    			frame:true,
    			labelAlign:"right",
    	        width:340,
    	        border:false,
    	        waitMsgTarget: true,
    	        region:"north",
    	        layout:"form",
    			items:[
    		    	   	
    		    	   	new Ext.form.ComboBox({
    		   			   id:'showInfoCombox',
    		   			   name:'showInfo',
    		               fieldLabel: '展会名称',
    		               hiddenName:'state',
    		               store: showInfoStore,
    		               valueField:'id',
    		               displayField:'showName',
    		               typeAhead: true,
    		               mode: 'local',
    		               triggerAction: 'all',
    		               emptyText:'请选择展会',
    		               selectOnFocus:false,
    		               width:240 
    		    	   	})
    			       ]
    			});
    		//根据展会查询调查问郑标题
    		Ext.getCmp("showInfoCombox").on('select',function(combo,record,index){
    			//当前选择的机构类的id
    			showId = Ext.getCmp('showInfoCombox').getValue();
    			var qTitleName = Ext.getCmp('showInfoCombox').getRawValue();

    			//根据选择的标题重新加载grid
    	  	  	  store.load({
    	  	  			params : {start : 0,limit : 9,showInfoId:showId}
    	  	  	  });
    		});
          	
		  var northPanel = new Ext.Panel({
			  id:"northPanel",
				region:"north",
				//split:"true",
				layout:"fit",
				height:70,
				items:[
					qTitleForm
				],
				tbar:[//定义顶部工具栏
		 				 {
		 				   id:'resendemail',
		                   text: '重新发送邮件',
		                   //iconCls : 'remove',
		                   //pressed : true,
		                   handler : function(){
		 					   var obArr = sm.getSelections();
		                   	   var selIDStr = "";
		                   	   if(obArr.length == 0){
			                   	   Ext.Msg.alert("提示","没有选中行");
			                   	   return;
		                   	   }
		                   	   for(var i=0;i<obArr.length;i++){
			                   	   if(selIDStr > 0){
			                   			selIDStr += ",";
			                   	   }
		                   		   selIDStr += obArr[i].id;
		                   	   }
			                   resendemail(selIDStr);
			               } 
			 			 },'-',{
			         	      id:'deletenode',
			                   text: '删除',
			                   iconCls : 'remove',
			                   //pressed : true,
			                   handler : function(){
			                       var obArr = sm.getSelections();
			                   	   var selIDStr = "";
			                   	   if(obArr.length == 0){
				                   	   Ext.Msg.alert("提示","没有选中行");
				                   	   return;
			                   	   }
			                   	   for(var i=0;i<obArr.length;i++){
				                   	   if(selIDStr > 0){
				                   			selIDStr += ",";
				                   	   }
			                   			selIDStr += obArr[i].id;
			                   	   }
				                   deleteAudience(selIDStr,store);
				              }
				           },"-",{
			         	       id:'exploreExcel',
			                   text: '导出Excel',
			                   iconCls : 'remove',
			                   handler : function(){
					        	   Ext.MessageBox.confirm("提示","确定生成Excel？",function(btn){
						      			 if(btn=="yes"){
					                	    window.location.href = "creatAudienceExcelAction.action?showId="+showId;
						      			 }
						           });
			                   }
		                  },"-",{
		                	  
		                	  id:'refresh',
			                  text: '刷新',
			                  iconCls : 'refresh',
			                  //pressed : true,
			                  handler : function(){
		                	  refresh(store);
		                  	  }
		                  }]
		  			});
  	  	      
  	  	  var centerPanel = new Ext.Panel({
	  	  		id:"centerPanel",
	  	  		layout:"border",
	  	  		region:"center",
	  	  		width:"75%",
	  	  		items:[
						//grid
						ct
	   	  	  		]
	  	  		
	  		});
  	  	var viewport = new Ext.Viewport({
			id : 'viewprot',
			layout : 'border',
			items : [
					northPanel,
					centerPanel
				]
		});
//		}  
	//});
  	}
  		Ext.onReady(InitMain); 
  	
  	
  	</script>
  </body>
</html>
